package com.informationsystem.webapp.action;

import java.util.List;

import com.informationsystem.model.Downloads;
import com.informationsystem.service.DownloadsManager;

public class InfoCenter_Downloads_Action extends BaseAction{
	private DownloadsManager downloadsManager;
	private List downloadsList;
	private Downloads downloads;
	private Long id;
	public DownloadsManager getDownloadsManager() {
		return downloadsManager;
	}

	public void setDownloadsManager(DownloadsManager downloadsManager) {
		this.downloadsManager = downloadsManager;
	}

	public List getDownloadsList() {
		return downloadsList;
	}

	public void setDownloadsList(List downloadsList) {
		this.downloadsList = downloadsList;
	}

	public Downloads getDownloads() {
		return downloads;
	}

	public void setDownloads(Downloads downloads) {
		this.downloads = downloads;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String list() {
		setDownloadsList(downloadsManager.getDownloadsList());
		return SUCCESS;
	}

	public String view() {
		if (getId() != null) {
			setDownloads(downloadsManager.get(getId()));
			downloads.setViewTimes(downloads.getViewTimes() + 1);
			downloadsManager.save(downloads);
		} else {
			setDownloads(new Downloads());
		}

		return SUCCESS;
	}
}
